{include file="public/header" /}
</head>
<body>
<form class="layui-form layui-form-pane" action="" style="padding: 20px;">
    <input type="hidden" name="designer_id" value="{$dataInfo.designer_id|default=0}">
    <input type="hidden" name="crm_designer_id" value="{$dataInfo.crm_designer_id|default=''}">
    <input type="hidden" name="designer_design_case" value="{$dataInfo.designer_design_case|default=''}">
    {notempty name="SUBSTATIONS"}
    <input type="hidden" name="substation_id" value="{$dataInfo.substation_id|default=$SUBSTATIONS}">
    {/notempty}
    <div class="layui-form-item">
        <label class="layui-form-label">设计师名称</label>
        <div class="layui-input-inline" style="width: 40%">
            <input type="text" name="designer_name" required lay-verify="required"  placeholder="请输入设计师名称" autocomplete="off" class="layui-input" value="{$dataInfo.designer_name|default=''}">
        </div>
        <button class="layui-btn" type="button" id="get_designer_name">绑定设计师</button>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">手机号码</label>
        <div class="layui-input-block">
            <input type="text" name="designer_tel"  placeholder="请输入手机号码" autocomplete="off" class="layui-input" value="{$dataInfo.designer_tel|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">设计师级别</label>
        <div class="layui-input-block my-width" >
            <select name="designer_level" lay-search placeholder="请选择设计师级别" required lay-verify="required">
                <option value="">请选择</option>
                {notempty name="DesignerLevel"}
                {volist name="DesignerLevel" id="tl"}
                <option value="{$tl.config_id}" {present name="dataInfo.designer_level"}{if condition="$tl['config_id'] == $dataInfo['designer_level']"}selected{/if}{/present}>{$tl.config_name}</option>
                {/volist}
                {/notempty}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">排序</label>
        <div class="layui-input-block">
            <input type="text" name="sort" required lay-verify="required"  placeholder="请输入排序，（0 - 999）" autocomplete="off" class="layui-input" value="{$dataInfo.sort|default=''}">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">从业年限</label>
        <div class="layui-input-block">
            <input type="text" name="years"  placeholder="请输入从业年限" autocomplete="off" class="layui-input" value="{$dataInfo.years|default=''}">
        </div>
    </div>
    <div class="layui-form-item" pane>
        <label class="layui-form-label">是否显示</label>
        <div class="layui-input-block">
            {notempty name="RadioIs"}
            {volist name="RadioIs" id="vo"}
            <input type="radio" name="is_display" value="{$key}" title="{$vo}" {present name="dataInfo.is_display"}{eq name="dataInfo.is_display" value="$key"}checked{/eq}{else/}{eq name="key" value="1"}checked{/eq}{/present}>
            {/volist}
            {/notempty}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label ">代表作品</label>
        <div class="layui-input-inline" style="width: 60%">
            <input type="text" id="drawing_id_text"  autocomplete="off" class="layui-input" value="{$dataInfo.representative_works_text|default=''}" placeholder="请选择图纸" readonly >
            <input type="hidden" name="representative_works"  autocomplete="off" class="layui-input" value="{$dataInfo.representative_works|default=''}" placeholder="请选择图纸">
        </div>
        <button class="layui-btn" type="button" id="get_drawing">选择图纸</button>
        <button class="layui-btn" type="button" id="get_drawing_null">清空</button>
    </div>
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">设计师个人介绍</label>
        <div class="layui-input-block">
            <textarea name="introduce" placeholder="请输入设计师个人介绍" class="layui-textarea">{$dataInfo.introduce|default=''}</textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-upload">
            <button type="button" class="layui-btn" id="test1">上传设计师照片</button>
            <div class="layui-upload-list"  style="width: 350px;height: 350px;">
                <input type="hidden" name="photo" id="photo" value="{$dataInfo.photo|default=''}" placeholder="请上传设计师照片">
                <img class="layui-upload-img" id="photo_img" src="{$dataInfo.photo|default=''}">
            </div>
        </div>
    </div>
    {empty name="SUBSTATIONS"}
    <div id="substation_type">
        <div class="layui-form-item" pane>
            <label class="layui-form-label">发布网站</label>
            <div class="layui-input-block">
                {notempty name="userSubstationList"}
                {volist name="userSubstationList" id="vo"}
                <input type="radio" name="substation_id" value="{$vo.substation_id}" title="{$vo.substation_name}"  {notempty name="dataInfo.substation_id"}{if condition="$dataInfo['substation_id'] eq $vo['substation_id']"}checked{/if}{/notempty}>
                {/volist}
                {/notempty}
            </div>
        </div>
    </div>
    {/empty}
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" type="button" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
</body>
<script>
    var form;
    layui.use(['form','upload'], function(){
        form = layui.form;var upload = layui.upload;;
        form.render();
        //监听提交
        form.on('submit(formDemo)', function(data){
            post_sub("{:url('Designers/add')}",data.field);
            return false;
        });
        //上传居中水印图
        upload.render({
            elem: '#test1'
            ,url: "{:url('FileOperation/uploadImg',['type'=>'DesignerPhoto'])}"
            ,before: function(obj){
                UploadIndex = layer.msg('图片上传中', {
                    icon: 16
                    ,shade: 0.01
                    ,time:0
                });
            }
            ,done: function(res){
                layer.close(UploadIndex);
                layer.msg(res.msg);
                //如果上传失败
                if(parseInt(res.code) == 0){
                    //上传成功-默认赋值
                    $("#photo").val(res.url);
                    $("#photo_img").attr("src",res.url);
                }
            }
        });
        //绑定设计师
        $("#get_designer_name").click(function () {
            var openIndex = layer.open({
                type: 2,
                title:"绑定设计师",
                area: ["100%", "100%"],
                skin: 'layui-layer-rim',
                scrollbar: false,
                content: "{:url('Designers/bindingDesigner')}",
            });
        });
        //代表作品
        $("#get_drawing").click(function () {
            var openIndex = layer.open({
                type: 2,
                title:"选择代表作品",
                area: ["100%", "100%"],
                skin: 'layui-layer-rim',
                scrollbar: false,
                content: "{:url('Designers/choiceDrawing')}",
            });
        });
        //清空
        $("#get_drawing_null").click(function () {
            $('input[name=representative_works]').val('');
            $('#drawing_id_text').val('');
        });
    });
</script>
</html>